package com.ruoyi.web.controller.aj;

import com.ruoyi.aj.domain.Case_law;
import com.ruoyi.aj.service.ICaseExamservice;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.DataSourceType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * @Author: Wang
 * @Date: 2024/6/14 9:27
 * @Description:
 */


//案件
@RestController
@RequestMapping("/CaseExam")
@DataSource(DataSourceType.SLAVE)
public class CaseExamcontroller extends BaseController {
    @Autowired
    private ICaseExamservice service;
    @GetMapping("/listall")
    public  Object query(Case_law caseLaw){
        List<Case_law> list =service.listall(caseLaw);
        System.out.println(list.toString());
        return getDataTable(list);
    }
    @GetMapping("/inscaselaw")
    public  Object inscaselaw(Case_law caseLaw){
        System.out.println(caseLaw.toString());
        caseLaw.setCaseSettleStatus("N");
        caseLaw.setCasePlan("A");
        caseLaw.setCaseApproveStatus("1");
        caseLaw.setCaseAssign("Y");
        caseLaw.setCaseSubtime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        caseLaw.setCollectionTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        caseLaw.setCaseContract("1");
        caseLaw.setCaseRecord("1");
        caseLaw.setCaseShare("1");
        caseLaw.setCaseSettleType("4");
        caseLaw.setCaseApprovalEndtime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
        caseLaw.setCaseClash("无");
        caseLaw.setCaseUnpaidsal(caseLaw.getCaseAgencyfee()-caseLaw.getCaseSubsidysal());
        return service.save(caseLaw);
    }
}
